define(['./../initial', './../service/chartsFactory'], function() {
    var app = angular.module('App.home');
    app.directive('singlePointQuery', ['$rootScope', '$q', 'chartsFactory',
        function($rootScope, $q, chartsFactory) {
            return {
                restrict: 'A',
                scope: {
                    'startDate': '@',
                    'endDate': '@',
                    'pointName': '@'
                },
                link: function(scope, el, attrs) {
                    scope.closeModal = function() {
                        $('#singleChartModal').modal('hide');
                    };
                    scope.summarySubmit = function() {
                        $rootScope.curPrj.getSinglePointRecentChanges(scope.pointName, 'custom', scope.startDate, scope.endDate).
                        then(function(data) {
                            chartsFactory.createSinglePointChangesChart('#singleChart', data);
                        });
                    };

                },
                templateUrl: 'partials/singlePointQuery.html'
            };
        }
    ]);

});
